package com.cyy;

import java.sql.SQLException;
import java.util.Random;

import com.cyy.dao.productDao;
//生成1000条数据
public class test {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        productDao productDao = new productDao();
        int i = productDao.getMaxid();
        System.out.println(i);
        String[] names=new String[1000];
        int[] prices=new int[1000];
        int[] reserves=new int[1000];
        int[] solds=new int[1000];
        String[] covers=new String[1000];
        for(int k=0;k<1000;k++)
        {
            names[k]="product "+String.valueOf(k+i+1);
            Random r=new Random();
            reserves[k]=r.nextInt(1000);
            solds[k]=r.nextInt(1000);
            prices[k]=r.nextInt(50);
            if(prices[k]<5)
            {
                prices[k]+=10;
            }
            if((k+i+1)%40+1<=10)
            {
                prices[k]+=70;
            }
            covers[k]="images/product-"+String.valueOf((k+i+1)%40+1)+".jpg";
        }
        productDao.addProduct(names,prices,reserves,solds,covers);
    }
}
